<?php

namespace App\Http\Controllers\Sale;

use App\Http\Controllers\Base\Base;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class Delete extends Controller
{
    private $baseClass;

    function __construct()
    {
        $this->baseClass = new Base();
    }

    public function delete(){
        $data = array();
        if ($this->baseClass->checkLoginStatus() === true){
            $id = $this->baseClass->htmlPurifier('id');
            if ($id != ''){
                DB::table($this->baseClass->recordTable)
                    ->where('id', '=', $id)
                    ->delete();
                $status = 0;
                $content = '删除成功';
            }
            else {
                $status = 201;
                $content = '参数不能为空';
            }
        }
        else {
            $status = 101;
            $content = '尚未登录';
        }
        return $this->baseClass->returnJson($status, $content, $data);
    }
}
